package 牛客_面试必刷.Month07.day10;

public class 二叉树的镜像 {
    public TreeNode Mirror (TreeNode pRoot) {
        // write code here
        if(pRoot == null) return null;
        if(pRoot.left == null && pRoot.right == null) return pRoot;
        solve(pRoot);
        return pRoot;
    }

    public void solve(TreeNode root){
        if(root == null) return;
        TreeNode tmp = root.left;
        root.left = root.right;
        root.right = tmp;
        solve(root.left);
        solve(root.right);
    }
}
